package com.aya.transaction.service;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;

@Service
public class BlogNeverTransactionService {
    @Resource
    BlogSimpleTransactionService blogSimpleTransactionService;

    @Transactional
    public int updateByIdSuccess(String id, String content, String id2, String content2) {
        int i = blogSimpleTransactionService.updateById(id, content);
        blogSimpleTransactionService.updateByIdNever(id2, content2);
        return i;
    }

    @Transactional
    public int updateByIdInnerFailure(String id, String content, String id2, String content2) {
        int i = blogSimpleTransactionService.updateById(id, content);
        blogSimpleTransactionService.updateByIdNeverException(id2, content2);
        return i;
    }

    public int updateByIdOuterSuccess(String id, String content, String id2, String content2) {
        int i = blogSimpleTransactionService.updateById(id, content);
        blogSimpleTransactionService.updateByIdNever(id2, content2);
        return i;
    }

    public int updateByIdOuterFailure(String id, String content, String id2, String content2) {
        int i = blogSimpleTransactionService.updateById(id, content);
        blogSimpleTransactionService.updateByIdNeverException(id2, content2);
        throw new RuntimeException("exception");
    }

}
